package com.mpsc.lcn.provide.controller;


import com.codingapi.txlcn.tc.annotation.DTXPropagation;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.mpsc.api.bean.RoleInfoEntity;
import com.mpsc.lcn.provide.service.RoleInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/roleInfo")
@Api(value = "RoleInfoController", tags = "角色管理")
public class RoleInfoController {

    @Autowired
    private RoleInfoService roleInfoService;

    @GetMapping("/find/role-by-id")
    @ApiOperation("findRoleById")
    @LcnTransaction(propagation= DTXPropagation.REQUIRED)
    public void findRoleById(@RequestParam("id") Long id) {
        System.out.println("--------------通过角色id查询角色------------");
    }


    @PostMapping("/save")
    @ApiOperation("保存角色信息")
    @LcnTransaction(propagation= DTXPropagation.REQUIRED)
    @Transactional
    public void save(@RequestBody RoleInfoEntity role) {
        System.out.println("--------------保存角色之前------------");
       roleInfoService.saveRoleInfo(role);
    }

    @GetMapping("/find/role")
    @ApiOperation("findRole")
    @LcnTransaction(propagation= DTXPropagation.SUPPORTS)
    @Transactional
    public void findRole() {
        System.out.println("--------------findRole查询所有的角色------------");
    }
}
